package com.pipi.fanglan.filter;

import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by pipi on 2017/7/16.
 */
public class SessionFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest,
                                    HttpServletResponse httpServletResponse,
                                    FilterChain filterChain) throws ServletException, IOException {


        String path = httpServletRequest.getContextPath();
        if("/".equals(path)){
            httpServletResponse.sendRedirect("/monitor/login");
            doFilter(httpServletRequest,httpServletResponse,filterChain);
        }
    }
}
